﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CONTROLLER;

namespace VIEW.Login {
    public partial class NewAccount : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {

        }

        protected void btnCancel_Click(object sender, EventArgs e) {
            Response.Redirect("~/Login/Login.aspx", true);
        }

        protected void btnCreate_Click(object sender, EventArgs e) {
            if (txtFname.Text != string.Empty) {
                if (txtMname.Text != string.Empty) {
                    if (txtLname.Text != string.Empty) {
                        if (txtUname.Text != string.Empty) {
                            if (txtPword.Text != string.Empty) {
                                if (txtPword.Text == txtCPword.Text) {
                                    LoginControl login = new LoginControl();
                                    login.saveUser(txtFname.Text, txtMname.Text, txtLname.Text, txtUname.Text + txtPword.Text);
                                } else {
                                    errorWrongUP.IsValid = false;
                                }
                            } else {
                                errorWrongUP.IsValid = false;
                            }
                        } else {
                            errorWrongUP.IsValid = false;
                        }
                    } else {
                        errorWrongUP.IsValid = false;
                    }
                } else {
                    errorWrongUP.IsValid = false;
                }
            } else {
                errorWrongUP.IsValid = false;
            }
        }
    }
}